package convertTestsTojUnit;

import executor.ReflectionExecutor;
import ga.GAInfo;
import ga.Individual;

import java.io.File;
import java.util.Calendar;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;


import model.TestClusterBuilder;
import operations.Operation;
import util.GAConfig;
import util.GAOperationsConfig;
import util.Log;
import util.Randomness;

public class TestConvertJUnitTestGen {
	public static void main(String[] args) {
	       GAInfo     gaInfo     = new GAInfo();
			long startTime = Calendar.getInstance().getTimeInMillis();
			gaInfo.setTestTimeOut(60 * 500);
			 gaInfo.setTestTimeOut( 60 * 1000*10); ;
				gaInfo.setStartTime(startTime);


		Randomness.reset(20);
		
		 Set<Class<?>> allClasses = new LinkedHashSet<Class<?>>();
	      //get class from file
	      allClasses.addAll(TestClusterBuilder.readClassFromFile());

	      
	      TestClusterBuilder TestCluster = new TestClusterBuilder(allClasses);
	      gaInfo.setTestCluster(TestCluster);
		  List<Operation> initialConstructors= Operation.generateInitialConstructors(TestCluster);
	      List<Operation> ops=new LinkedList<Operation>();
    	  ops.addAll(Operation.randomlyGenerate(TestCluster,10));
	      Individual individual1=new Individual(initialConstructors,ops);
	      
	//      ReflectionExecutor.execute(gaInfo,individual1);
				
	
				System.out.println("1)\n" + individual1.toString());
			
				Map<Integer,Individual> branchCoveredByIndividual = new HashMap<Integer, Individual>() ;
			
				 branchCoveredByIndividual.put(1, individual1);
				 
				JUnitTestGenerator gen = new JUnitTestGenerator(GAConfig.getDirGeneratedTests(),gaInfo,branchCoveredByIndividual);
			//	gen.read(branchCoveredByIndividual);
				gen.writeSuite();
//				ReflectionExecutor.execute(gaInfo,offspring[0]);
//				ReflectionExecutor.execute(gaInfo,offspring[1]);
				System.exit(0);

	}

}
